package com.jiang.smartcommunity.ui.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.utils.widget.ImageFilterView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.jiang.smartcommunity.MainActivity;
import com.jiang.smartcommunity.R;
import com.jiang.smartcommunity.tool.MyAdapter;

import java.util.Arrays;
import java.util.List;

public class S2Activity extends BaseActivity {

    private RecyclerView rv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_s2);
        initView();
        setTitle("快件管理");
    }

    private void initView() {
        rv = (RecyclerView) findViewById(R.id.rv);
        rv.setLayoutManager(new LinearLayoutManager(getThis()));
        List<MainActivity.NotifyBean> notifyBeans = Arrays.asList(
                new MainActivity.NotifyBean("顺丰快递点", "710m", R.drawable.s3),
                new MainActivity.NotifyBean("顺丰快递点", "930m", R.drawable.s3),
                new MainActivity.NotifyBean("菜鸟快递点", "540m", R.drawable.s4),
                new MainActivity.NotifyBean("菜鸟快递点", "1710m", R.drawable.s4));
        rv.setAdapter(new MyAdapter<MainActivity.NotifyBean>(getThis(), R.layout.item_s2, notifyBeans) {
            private ImageFilterView imageView6;
            private TextView textView9;
            private TextView textView11;

            @Override
            public void init(View root, int position) {
                imageView6 = (ImageFilterView) root.findViewById(R.id.imageView6);
                textView9 = (TextView) root.findViewById(R.id.textView9);
                textView11 = (TextView) root.findViewById(R.id.textView11);

                MainActivity.NotifyBean item = getItem(position);
                imageView6.setImageResource(item.res);
                textView11.setText(item.c);
                textView9.setText(item.t);
                root.setOnClickListener(v -> {
                    startActivity(new Intent(getThis(),S2DActivity.class));
                });
            }
        });
    }
}